"use strict";
cc._RF.push(module, '65ca9zMFmRPGrylqVyuZatl', 'jr');
// Script/jr.js

"use strict";

cc.Class({
  "extends": cc.Component,
  properties: {
    topNode: {
      "default": null,
      type: cc.Node
    },
    realplayer: {
      "default": null,
      type: cc.Node
    },
    nexttools: {
      "default": null,
      type: cc.Node
    }
  },
  //显示升级界面--预制体
  showTip: function showTip(event, customEventData) {
    var CanvasNode = this.topNode;

    if (!CanvasNode) {
      cc.log('find Canvas error');
      return;
    }

    if (step != 6) {
      var onResourceLoaded = function onResourceLoaded(errorMessage, loadedResource) {
        if (errorMessage) {
          cc.log('Prefab error:' + errorMessage);
          return;
        }

        if (!(loadedResource instanceof cc.Prefab)) {
          cc.log('Prefab error');
          return;
        }

        var newMyPrefab = cc.instantiate(loadedResource);
        CanvasNode.addChild(newMyPrefab, 100);
        newMyPrefab.setPosition(0, 0);
        var newMyPrefabScript = newMyPrefab.getComponent('AlertMsg');
        newMyPrefabScript.setLabelString(errormsg);
      };

      if (isShow == 0) {
        isShow = !isShow;
        cc.resources.load('AlertMsg', onResourceLoaded);
      }
    } else {
      // var anim = this.realplayer.getComponent(cc.Animation);
      // var animState = anim.play('step1');
      // anim.pause('step1');
      var that = this;
      var sendData = {
        "TaskGuid": "slkdjflie09876",
        "DataType": "usergy",
        "userid": "1"
      }; //获取网络数据

      var xhr = new XMLHttpRequest();

      xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
          var response = xhr.responseText; //console.log(response);
          //console.log("==============");

          var info = eval('(' + response + ')');
          var infores = eval('(' + info + ')');
          stepstatus = infores.status;
          waittime = infores.setlog.waittime;
          waitminutes = infores.setlog.waitminutes; //

          if (stepstatus == 0) {
            var onResourceLoaded = function onResourceLoaded(errorMessage, loadedResource) {
              if (errorMessage) {
                cc.log('Prefab error:' + errorMessage);
                return;
              }

              if (!(loadedResource instanceof cc.Prefab)) {
                cc.log('Prefab error');
                return;
              }

              var newMyPrefab = cc.instantiate(loadedResource);
              CanvasNode.addChild(newMyPrefab, 100);
              newMyPrefab.setPosition(0, 0);
              var newMyPrefabScript = newMyPrefab.getComponent('Pregress'); //newMyPrefabScript.setLabelString("开始浸润！");

              newMyPrefabScript.onConfirBtn(function () {
                //cc.log('开始粉碎');
                //获取数据
                var sendData = {
                  "TaskGuid": "slkdjflie09876",
                  "DataType": "gameset",
                  "user_id": "1",
                  "set_code": "6",
                  "status": "1"
                }; //cc.log(sendData);
                //获取网络数据

                var xhr = new XMLHttpRequest();

                xhr.onreadystatechange = function () {
                  if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
                    var response = xhr.responseText;
                    cc.log(response); //console.log("==============");	

                    var _info = eval('(' + response + ')');

                    var _infores = eval('(' + _info + ')');

                    cc.log(_infores);
                  }
                }; // xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);


                xhr.open("GET", seturl + JSON.stringify(sendData), true);
                xhr.send();
              });
            };

            if (isShow == 0) {
              isShow = !isShow;
              cc.resources.load('Pregress', onResourceLoaded);
            }
          } else {
            if (waitminutes < 0 || waitminutes == 0) {
              //======
              var onResourceLoaded = function onResourceLoaded(errorMessage, loadedResource) {
                if (errorMessage) {
                  cc.log('Prefab error:' + errorMessage);
                  return;
                }

                if (!(loadedResource instanceof cc.Prefab)) {
                  cc.log('Prefab error');
                  return;
                }

                var newMyPrefab = cc.instantiate(loadedResource);
                CanvasNode.addChild(newMyPrefab, 100);
                newMyPrefab.setPosition(0, 0);
                var newMyPrefabScript = newMyPrefab.getComponent('Alert');
                newMyPrefabScript.setLabelString("好的，接下来请发酵！");
                newMyPrefabScript.onConfirBtn(function () {
                  step = 7; //cc.log('开始粉碎');
                  //获取数据

                  var sendData = {
                    "TaskGuid": "slkdjflie09876",
                    "DataType": "gameset",
                    "user_id": "1",
                    "set_code": "6",
                    "status": "2"
                  };
                  cc.log(sendData); //获取网络数据

                  var xhr = new XMLHttpRequest();

                  xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4 && xhr.status >= 200 && xhr.status < 400) {
                      var response = xhr.responseText;
                      cc.log(response); //console.log("==============");	

                      var _info2 = eval('(' + response + ')');

                      var _infores2 = eval('(' + _info2 + ')');

                      cc.log(_infores2);
                    }
                  }; // xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);


                  xhr.open("GET", seturl + JSON.stringify(sendData), true);
                  xhr.send();
                });
              };

              if (isShow == 0) {
                isShow = !isShow;
                cc.resources.load('Alert', onResourceLoaded);
              } //======

            } else {
              var onResourceLoaded = function onResourceLoaded(errorMessage, loadedResource) {
                if (errorMessage) {
                  cc.log('Prefab error:' + errorMessage);
                  return;
                }

                if (!(loadedResource instanceof cc.Prefab)) {
                  cc.log('Prefab error');
                  return;
                }

                var newMyPrefab = cc.instantiate(loadedResource);
                CanvasNode.addChild(newMyPrefab, 100);
                newMyPrefab.setPosition(0, 0);
                var newMyPrefabScript = newMyPrefab.getComponent('AlertMsg');
                newMyPrefabScript.setLabelString('倒计时:' + waittime);
              };

              if (isShow == 0) {
                isShow = !isShow;
                cc.resources.load('AlertMsg', onResourceLoaded);
              } //cc.loader.loadRes('background', onResourceLoaded );

            }
          }
        }
      }; // xhr.open("GET", seturl+'/'+JSON.stringify(sendData), true);


      xhr.open("GET", url + JSON.stringify(sendData), true);
      xhr.send(); //===================================
    }
  },
  // LIFE-CYCLE CALLBACKS:
  // onLoad () {},
  start: function start() {} // update (dt) {},

});

cc._RF.pop();